package com.neusoft.resturant.controller;


import com.neusoft.resturant.common.utils.R;
import com.neusoft.resturant.entity.ResComment;
import com.neusoft.resturant.service.IResCommentService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;


import java.util.List;

/**
 * 评论Controller
 *
 * @author ruoyi
 * @date 2023-12-15
 */
@RestController
@RequestMapping("/res/comment")
public class ResCommentController
{
    @Autowired
    private IResCommentService resCommentService;

    /**
     * 查询评论列表
     */

    @GetMapping("/list")
    public R list(ResComment resComment)
    {

        List<ResComment> list = resCommentService.selectResCommentList(resComment);
        return R.success(list);
    }

    /**
     * 获取评论详细信息
     */

    @GetMapping(value = "/{id}")
    public R getInfo(@PathVariable("id") Long id)
    {
        return R.success(resCommentService.selectResCommentById(id));
    }

    /**
     * 新增评论
     */

    @PostMapping
    public R add(@RequestBody ResComment resComment)
    {
        return R.toAjax(resCommentService.insertResComment(resComment));
    }

    /**
     * 修改评论
     */

    @PutMapping
    public R edit(@RequestBody ResComment resComment)
    {
        return R.toAjax(resCommentService.updateResComment(resComment));
    }

    /**
     * 删除评论
     */

	@DeleteMapping("/{ids}")
    public R remove(@PathVariable Long[] ids)
    {
        return R.toAjax(resCommentService.deleteResCommentByIds(ids));
    }
}
